import {
	createStore
} from 'vuex';

export default createStore({
	state() {
		return {
			userinfo: "用户信息", //获得本地储存的用户信息this.$store.state.userinfo
			token: ""
		};
	},
	getters: {
		getToken(state) { // 获取token
			return state.token;
		}
	},
	mutations: { //唯一修改state的方法
		login(state) { //用户信息修改this.$store.commit("login")
			state.token = localStorage.getItem("token");
		},
		delToken(state) { //用户信息清空this.$store.commit("delToken")
			state.token = '';
			localStorage.removeItem("token");
		}
	}
})